package com.gistone.commis.entity;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.util.Assert;

import javax.persistence.*;
import java.util.List;
/**
 * Created by wangfan on 2017/5/1.
 */
@Setter
@Getter
public class Role implements GrantedAuthority {

    private static final long serialVersionUID = 5635641430953788465L;

    // Predefiend User roles
    public static final Role ROLE_ADMIN = new Role(1, "ADMIN");
    public static final Role ROLE_CURATOR = new Role(2, "CURATOR");
    public static final Role ROLE_USER = new Role(3, "USER");

    @Id
    int roleId;

    @Column(unique = true)
    String roleName;


    public Role() {

    }

    public Role(int id, String name) {
        this.roleId = id;
        Assert.hasText(name, "A granted authority textual representation is required");
        this.roleName = name;
    }

    @Override
    public String getAuthority() {
        return roleName;
    }

}
